package com.app.megaprosoft.DB;

import java.io.File;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;

import com.app.megaprosoft.general.DateTime;
import com.app.megaprosoft.modyimcarcare.Carcare_Login;

import android.app.Application;
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.location.Address;
import android.os.Environment;
import android.util.Log;

public class SQLiteDB_POSList extends SQLiteOpenHelper {

	ResultSet rs = null;
	// Database Version
	private static final int DATABASE_VERSION = 1;

	// Database Name
	private static final String DATABASE_NAME = "MegaAutoCare";

	// Service
	private static final String TABLE_ServicePOSLists = "_ServicePOSLists";

	public SQLiteDB_POSList(Context context) {
		super(context, Environment.getExternalStorageDirectory()
				+ File.separator + "/DataBase/" + File.separator
				+ DATABASE_NAME, null, DATABASE_VERSION);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		
	
		try {
			db.execSQL("CREATE TABLE " + TABLE_ServicePOSLists
					+ "(ServicePOSListsOID TEXT(100) PRIMARY KEY,"
					
										+ " POSOID TEXT(100)," 
										+ " ItemOID TEXT(100),"
										+ " Qty TEXT(100)," 
										+ " Price TEXT(100),"
										+ " TotalAmount TEXT(100),"
					
										+ " Discount TEXT(100)," 
										+ " NetAmount TEXT(100),"
										+ " UnitOID TEXT(100)," 
										+ " WHOID TEXT(100),"
										+ " ICZoneOID TEXT(100),"
					
										+ " ICStorageOID TEXT(100)," 
										+ " ICShelfOID TEXT(100),"
										+ " ICColumnOID TEXT(100),"
										+ " StkInOutDateTime TEXT(100)," 
										+ " Status TEXT(100),"
					
										+ " UserModify TEXT(100)," 
										+ " CreateTime TEXT(100),"
										+ " LastUpdate TEXT(100)," 
										+ " StatusUpdate TEXT(100),"
										+ " StatusDoc TEXT(100));");

		} catch (Exception e) {

		}

		Log.d("CREATE TABLE", "Create Table Successfully.");
	}

	public void Clear_table() {
		SQLiteDatabase db;
		db = this.getWritableDatabase();
		onUpgrade(db, 0, 1);
	}

	
	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL("DROP TABLE IF EXISTS " + TABLE_ServicePOSLists);
		// Re Create on method onCreate
		onCreate(db);
	}

}
